/*eslint-disable */
import common from "@common/api/common";
import constants from "../constants";
import apiConstants from "@common/api/constants";
import { message } from '@common/assets/js/resetMessage';

export default {
    namespaced: true,
    state: {
        printTypeList: [],
        cfgTypeList: constants.cfgTypeList,
    },
    mutations: {
        SET_PRINT_TYPE_LIST: (state, list) => {
            state.printTypeList = list;
        },
    },
    actions: {
        initPrintTypeList({ commit }) {
            return common.requestData(apiConstants.API_FindCommonParameterValuesByKey, {
                key1: 'print_design_type',
            }).then(result => {
                let resData = result.data || [];
                commit('SET_PRINT_TYPE_LIST', resData);
                return resData;
            }).catch(err => {
                message.error(err.message);
                return [];
            });
        },
        getAutoOrderCode(store, data = {}) {
            return common.requestData(apiConstants.API_GetAutoOrderCode, data).then(result => {
                if (result.code !== 0) {
                    return Promise.reject(result);
                }
                return result.data || '';
            }).catch(err => {
                message.error(err.message);
                return '';
            });
        },
    },
}
